package com.leyou.item.mapper;

import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {
    @Select("SELECT b.id, b.name, b.letter, b.image FROM tb_category_brand cb INNER JOIN tb_brand b ON b.id = cb.brand_id WHERE cb.category_id = #{cid}")
    List<Brand> queryByCategoryId(@Param("cid") Long cid);

    int saveCategoryBrand(@Param("categoryIds") List<Long> categoryIds, @Param("brandId") Long brandId);

    @Delete("DELETE FROM tb_category_brand WHERE brand_id = #{brandId}")
    int deleteCategoryBrandOfBrand(@Param("brandId")Long brandId);
}